// 需求管理 - 所有需求数据都在这里统一管理
import type { Requirement } from '../types/requirement';

export const requirementData: Requirement[] = [
  {
    id: 1,
    code: 'REQ-001',
    title: '用户登录功能',
    description: '实现用户登录功能，包括用户名密码登录和第三方登录',
    category: '功能需求',
    project: 'KZ-DevOps平台',
    status: '已完成',
    priority: '高',
    submitter: '张三',
    assignee: '李四',
    progress: 100,
    deadline: '2024-01-15',
    createdAt: '2024-01-01',
    updatedAt: '2024-01-15',
    estimatedHours: 40,
    actualHours: 38,
    tags: ['登录', '认证', '安全'],
    attachments: []
  },
  {
    id: 2,
    code: 'REQ-002',
    title: '项目管理模块',
    description: '开发项目管理功能，包括项目创建、编辑、删除等操作',
    category: '功能需求',
    project: 'KZ-DevOps平台',
    status: '开发中',
    priority: '高',
    submitter: '张三',
    assignee: '王五',
    progress: 75,
    deadline: '2024-02-01',
    createdAt: '2024-01-10',
    updatedAt: '2024-01-20',
    estimatedHours: 80,
    actualHours: 60,
    tags: ['项目', '管理', 'CRUD'],
    attachments: []
  },
  {
    id: 3,
    code: 'REQ-003',
    title: '任务看板功能',
    description: '实现任务看板，支持拖拽操作和状态更新',
    category: '功能需求',
    project: 'KZ-DevOps平台',
    status: '设计中',
    priority: '中',
    submitter: '李四',
    assignee: '赵六',
    progress: 30,
    deadline: '2024-02-15',
    createdAt: '2024-01-15',
    updatedAt: '2024-01-25',
    estimatedHours: 60,
    actualHours: 18,
    tags: ['任务', '看板', '拖拽'],
    attachments: []
  },
  {
    id: 4,
    code: 'REQ-004',
    title: '报表统计功能',
    description: '开发项目进度报表和团队效率统计',
    category: '功能需求',
    project: 'KZ-DevOps平台',
    status: '规划中',
    priority: '中',
    submitter: '王五',
    assignee: '钱七',
    progress: 0,
    deadline: '2024-03-01',
    createdAt: '2024-01-20',
    updatedAt: '2024-01-20',
    estimatedHours: 100,
    actualHours: 0,
    tags: ['报表', '统计', '分析'],
    attachments: []
  },
  {
    id: 5,
    code: 'REQ-005',
    title: '权限管理系统',
    description: '实现基于角色的权限控制(RBAC)',
    category: '功能需求',
    project: 'KZ-DevOps平台',
    status: '测试中',
    priority: '紧急',
    submitter: '张三',
    assignee: '李四',
    progress: 90,
    deadline: '2024-01-30',
    createdAt: '2024-01-05',
    updatedAt: '2024-01-25',
    estimatedHours: 50,
    actualHours: 45,
    tags: ['权限', 'RBAC', '安全'],
    attachments: []
  }
];

// 生成更多测试数据
for (let i = 6; i <= 50; i++) {
  const categories = ['功能需求', '性能需求', '安全需求', '界面需求'];
  const projects = ['KZ-DevOps平台', 'CRM系统', 'ERP系统', 'OA系统'];
  const statuses: Array<'规划中' | '设计中' | '开发中' | '测试中' | '已完成' | '已取消'> = ['规划中', '设计中', '开发中', '测试中', '已完成', '已取消'];
  const priorities: Array<'低' | '中' | '高' | '紧急'> = ['低', '中', '高', '紧急'];
  const submitters = ['张三', '李四', '王五', '赵六', '钱七'];
  const assignees = ['张三', '李四', '王五', '赵六', '钱七'];
  
  requirementData.push({
    id: i,
    code: `REQ-${i.toString().padStart(3, '0')}`,
    title: `需求标题${i}`,
    description: `这是第${i}个需求的详细描述`,
    category: categories[Math.floor(Math.random() * categories.length)],
    project: projects[Math.floor(Math.random() * projects.length)],
    status: statuses[Math.floor(Math.random() * statuses.length)],
    priority: priorities[Math.floor(Math.random() * priorities.length)],
    submitter: submitters[Math.floor(Math.random() * submitters.length)],
    assignee: assignees[Math.floor(Math.random() * assignees.length)],
    progress: Math.floor(Math.random() * 101),
    deadline: `2024-${(Math.floor(Math.random() * 12) + 1).toString().padStart(2, '0')}-${(Math.floor(Math.random() * 28) + 1).toString().padStart(2, '0')}`,
    createdAt: `2024-${(Math.floor(Math.random() * 12) + 1).toString().padStart(2, '0')}-${(Math.floor(Math.random() * 28) + 1).toString().padStart(2, '0')}`,
    updatedAt: `2024-${(Math.floor(Math.random() * 12) + 1).toString().padStart(2, '0')}-${(Math.floor(Math.random() * 28) + 1).toString().padStart(2, '0')}`,
    estimatedHours: Math.floor(Math.random() * 200) + 20,
    actualHours: Math.floor(Math.random() * 180),
    tags: ['标签1', '标签2', '标签3'],
    attachments: []
  });
}

// 需求状态分布数据
export const requirementStatusData = {
  labels: ['规划中', '设计中', '开发中', '测试中', '已完成', '已取消'],
  datasets: [
    {
      data: [
        requirementData.filter(r => r.status === '规划中').length,
        requirementData.filter(r => r.status === '设计中').length,
        requirementData.filter(r => r.status === '开发中').length,
        requirementData.filter(r => r.status === '测试中').length,
        requirementData.filter(r => r.status === '已完成').length,
        requirementData.filter(r => r.status === '已取消').length
      ],
      backgroundColor: [
        '#9CA3AF', // 规划中 - 灰色
        '#3B82F6', // 设计中 - 蓝色
        '#F59E0B', // 开发中 - 黄色
        '#8B5CF6', // 测试中 - 紫色
        '#10B981', // 已完成 - 绿色
        '#EF4444'  // 已取消 - 红色
      ]
    }
  ]
};

// 需求优先级分布数据
export const requirementPriorityData = {
  labels: ['低', '中', '高', '紧急'],
  datasets: [
    {
      data: [
        requirementData.filter(r => r.priority === '低').length,
        requirementData.filter(r => r.priority === '中').length,
        requirementData.filter(r => r.priority === '高').length,
        requirementData.filter(r => r.priority === '紧急').length
      ],
      backgroundColor: [
        '#10B981', // 低 - 绿色
        '#3B82F6', // 中 - 蓝色
        '#F59E0B', // 高 - 黄色
        '#EF4444'  // 紧急 - 红色
      ]
    }
  ]
};